<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
    //  数字求和游戏
        while(1){
             var base = Number(prompt("请输入基数"));
        var count = Number(prompt("请输入次数"));
        var first = base;
        var sum = 0;
        for(var i = 0;i < count;i++){
            sum =sum+base;
            base=base*10+first;
        }
        console.log(sum);
        alert(sum);
        var jixu = prompt("是否继续");
        if(jixu == 'y'){
            
        }else{
            break;
        }
        }
       
//闰年

      var count=0;
           for (var i = 1000; i <= 2000; i++) {
             if( i%4 == 0 && i%100 != 0 || i%400 == 0){
                document.write(i+" ");
                 count++;
             }
             if (count%4 == 0){
                document.write('<br/>');
             }
         }


//质数
    for (var i = 0; i <= 10000; i++) {
         for (var j = 2; j <= (i-1); j++){
             if((i%j) == 0 ){
                 break;
             }else if(j == (i-1)){
                 console.log(i);
                 document.write(i+" ");
             }
         }
        }

       //去除字符串中所有的空格

  
   var str = "  hello  world !  ";
   var str1 = str.replace(/\s/g,"");
   console.log(str1);

//字符串去重。
var str = "asdfgwertasdfsdfsdfersdfsdfgasdfg"
var newStr="";
	var flag;
	for(var i=0;i<str.length;i++){
		flag=1;
		for(var j=0;j<newStr.length;j++){
			if(str[i]==newStr[j]){
				flag=0;
				break;
			}
		}
		if(flag)  newStr+=str[i];
	}
    console.log(newStr);
//字符串反转
var name = "asdfgwertasdfsdfsdfersdfsdfgasdfg";
var result = name.split('').reverse().join(''); 
console.log(result);  

    </script>
</body>
</html>